module.exports = function ($scope, $state, $resource,$modal, $timeout, $stateParams, toaster) {

  /* 分页
      * ========================================= */
      $scope.maxSize = 5;            //最多显示多少个按钮
      $scope.bigCurrentPage = 1;      //当前页码
      $scope.itemsPerPage = 10;         //每页显示几条
      $scope.searchform = {};
    
      $scope.load = function () {
          var para = {
            spot_name:$scope.searchform.spot_name,
            pageNo: $scope.bigCurrentPage,
            pageSize: $scope.itemsPerPage,
            create_by: $scope.info.bind_seller_login_code
          };
          para = angular.extend($scope.searchform, para);
          $resource('/api/ac/ggc/faceDiscernService/findFDspoetList', {}, {}).save(para,function (res) {
    
            if (res.errcode !== 0) {
              alert(res.errmsg);
              $("#addsb").attr("style","display:none;");
              return;
            }
      
            $scope.objs = res.data.results;
            $scope.bigTotalItems = res.data.totalRecord;
            $scope.bigCurrentPage = res.data.pageNo;
      
          });
      };
    $scope.load();




    $scope.del = function (code) {
      if(confirm("您确认要删除吗？")){
      $resource('/api/as/ggc/facediscerndao/updateFDdelspot', {}, {}).save({'spot_code':code},function (res) {
        if (res.errcode === 0) {
          toaster.success({ title: "提示", body: "删除成功！"});
          $scope.load();
        } else {
          toaster.error({ title: "提示", body: res.errmsg });
        }
      });
    }
    }

    $scope.add = function (spot_code){
      var modalInstance = $modal.open({
        template: require('../views/createspot.html'),
        controller: 'createspot',
        size: 'xs',
        resolve: {
          spot_code:function(){
            return spot_code;
          },
          flag : function () {
            return spot_code == 1;
          },
        }
    });
    modalInstance.result.then(function (showResult) {	
      $scope.load();
    });
    }

    $scope.update = function (spot_code){
      var modalInstance = $modal.open({
        template: require('../views/createspot.html'),
        controller: 'createspot',
        size: 'xs',
        resolve: {
          spot_code:function(){
              return spot_code;
            },
            flag : function () {
              return spot_code == 1;
            },
        }
    });
    modalInstance.result.then(function (showResult) {	
      $scope.load();
    });
    }
      
  };


